Xbasic

A5_GET_RECORDS_IN_QUERY Function

Syntax

Record_Count as N = a5_get_records_in_query(C table_set_name ,C filter_expression [,N session_handle[,L count_child_records [,* OpDefn ]]])

Arguments

table_set_name

The name of the table or set. Include the ".set" suffix when working with a set.

filter_expression

A character filter expression that evaluates to a logical value. Selects records.

session_handle

Optional. Default = -1 (current session). Numeric

count_child_records

Logical. Optional. Default = .T. .T. = Count child records. .F. = Count only parent records.

OpDefn

*

Description

Returns the number of records in a query for a table or a set. To pass in arguments, set OpDefn.arguments = argument object

Discussion

The A5_GET_RECORDS_IN_QUERY() function returns the number of records in the specified table or set that satisfy a query expression.

Example

? a5_get_records_in_query("customer", "lastname > " + s_quote("M"))
= 27.000000
? a5_get_records_in_query("inventory.set", "cost > 2")
= 105

This is a good way to test if a table is empty. Assuming the table's name is customer :

if (a5_get_records_in_query("customer", .t.) = 0) then

This expression returns the number of records in the current query.

a5_get_records_in_query(current_filter_expn() )

See Also